import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBEngineer/YBBaseRouter/YBApplication.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBColor/YBColor.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/YBTextStyle/YBTextStyle.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBHelper/yb_chinese_text/yb_chinese_text.dart';
import 'package:yb_zsyiji_androidflutter_pro/YBJsonToModel/YBWorkTaiModel/YBWorkTaiBaseYiJiModel.dart';

import 'YBMiShuProvider/YBMiShuProvider.dart';
import 'YBMiShuSubPage/YBMiShuTongListSubPage.dart';
import 'YBMiShuSubPage/YBMiShuTongListYiHuoFeedStatusPage.dart';


enum mishuShangjiManagerTType {
  mishushangjiManagerTYpe_yijitong,
  mishushangjiManagerTYpe_lvsitong,
}


class YBYiLvSiListYiHuoManagerPage extends StatelessWidget {

  final mishuShangjiManagerTType type;

  const YBYiLvSiListYiHuoManagerPage({Key key, this.type}) : super(key: key);



  @override
  Widget build(BuildContext context) {

    String miType;

    if (type == mishuShangjiManagerTType.mishushangjiManagerTYpe_lvsitong) {
      miType = "xg_jinrilvsi";
    } else if (type == mishuShangjiManagerTType.mishushangjiManagerTYpe_yijitong) {
      miType = "xg_newyijiwang";
    }

    return Container(
      child: DefaultTabController(
        length: 2,
        child:Scaffold(
          appBar: AppBar(
            elevation: 0,
            title: Text(YBChineseText.workTaiShangJiManangerTitle,style: YBTextStyle.TextStyle30313320Medium),
            bottom: TabBar(
                indicatorSize: TabBarIndicatorSize.label,
                unselectedLabelColor: YBColor.color1B1C1F,
                labelColor: YBColor.commonThemeColor,
                indicatorColor: YBColor.commonThemeColor,
                tabs: [
                  Tab(text: YBChineseText.workTaiYouXiaoShangJiTitle,),
                  Tab(text: YBChineseText.workTaiYiYiShangJiTitle,),
                ]
            ),
          ),
          body:TabBarView(
            children: [
              Container(
                child: Column(
                  children: [
                    Container(
                    ),
                    Expanded(
                      child:ChangeNotifierProvider(
                        create: (context) => YBYiJiLvSiBaseYouXiaoProvider()..getYouXiaoDataList(1, miType,"1","3"),
                        child: Consumer<YBYiJiLvSiBaseYouXiaoProvider>(
                            builder: (context,youXiaoDataList,child){

                              return SmartRefresher(
                                controller:youXiaoDataList.easyRefreshController,
                                onLoading: () async {
                                  youXiaoDataList.loadData(miType,"1","3");
                                },
                                onRefresh: () async {
                                  youXiaoDataList.refreshData(miType,"1","3");
                                },
                                enablePullDown: true,
                                enablePullUp: true,
                                child: CustomScrollView(
                                  slivers: [
                                    SliverList(
                                      delegate: SliverChildBuilderDelegate((_,int index){
                                        YBWorkTaiBaseYiJiModel yiJiModel = youXiaoDataList.youXiaoModelList[index];
                                        return Container(
                                          child: InkWell(
                                            child: YBMiShuTongListSubPage(timeStr: yiJiModel.createTime,addressStr:'${yiJiModel.request.provinceName}-${yiJiModel.request.cityName}',contentStr: yiJiModel.request.requestServiceDesc,),
                                            onTap: () async {
                                              YBApplication.router.navigateTo(context, '/workTaiPage/workTaiLvSiTongPage/workTaiMiShuYouXiaoDetailPage?syscode=$miType&requestcode=${yiJiModel.requestCode}');
                                            },
                                          ),
                                        );
                                      },
                                        childCount: youXiaoDataList.youXiaoModelList.length,
                                      ),
                                    ),
                                  ],
                                ),
                              );
                            }
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              Container(
                child: Column(
                  children: [
                    Container(
                    ),
                    Expanded(
                      child: ChangeNotifierProvider(
                        create:(context) => YBYiJiLvSiBaseYiYiProvider()..getYiYiDataList(1, miType, "2","","",""),
                        child: Consumer<YBYiJiLvSiBaseYiYiProvider>(
                            builder: (context,yiYiList,child){

                              return SmartRefresher(
                                controller:yiYiList.easyRefreshController,
                                onRefresh: () async {
                                  yiYiList.refreshData(miType, "2","","","");
                                },
                                onLoading: () async {
                                  yiYiList.loadData(miType, "2","","","");
                                },
                                enablePullUp: true,
                                enablePullDown: true,
                                child: CustomScrollView(
                                  slivers: [
                                    SliverList(
                                      delegate: SliverChildBuilderDelegate((_,int index){
                                        YBWorkTaiBaseYiJiModel yijiModel = yiYiList.yiYiModelList[index];
                                        return Container(
                                          child: InkWell(
                                            child: YBMiShuTongYiHuoFeedStausPage(timeStr:yijiModel.updateTime,statusStr: 1.toString(),contentStr: yijiModel.requestServiceDesc,statusPageType: YBMiShuYiHuoFeedStatusPageType.YBMiShuYiHuoFeedStatusPageType_YiYiShangJi,),
                                            onTap: () async {
                                              YBApplication.router.navigateTo(context, '/workTaiPage/workTaiLvSiTongPage/workTaiMiShuYiYiDetailPage?syscode=$miType&requestcode=${yijiModel.requestCode}');
                                            },
                                          ),
                                        );
                                      },
                                        childCount: yiYiList.yiYiModelList.length,
                                      ),
                                    ),
                                  ],
                                ),
                              );
                            }
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
